package jsyf.oa.web.report;

import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import jsyf.com.util.BaseUtils;
import jsyf.com.util.ResponseUtils;
import jsyf.oa.facade.report.PersonnelFacade;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * Created by Administrator on 2018/2/24 0024.
 */
@Api(value = "人事报表接口", description = "人事报表接口")
@Controller
@RequestMapping("/personnel")
public class PersonnelController {
    @Resource
    private PersonnelFacade personnelFacade;


    @RequestMapping(value = "/getByUserId.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "人事卡片",
            notes = "人事卡片",
            httpMethod = "POST",
            response = ResponseUtils.class,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jsonData", value = "", dataType = "String", paramType = "body")
    })
    public void getByUserId(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject records = this.personnelFacade.getByUserId(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjRespond(records));
    }


    @RequestMapping(value = "/getEntryById.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "入职人员信息",
            notes = "入职人员信息",
            httpMethod = "POST",
            response = ResponseUtils.class,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jsonData", value = "", dataType = "String", paramType = "body")
    })
    public void getEntryById(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> records = this.personnelFacade.getEntryById(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(records));
    }

    @RequestMapping(value = "/getLeaveById.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "离职人员信息",
            notes = "离职人员信息",
            httpMethod = "POST",
            response = ResponseUtils.class,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jsonData", value = "", dataType = "String", paramType = "body")
    })
    public void getLeaveById(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> records = this.personnelFacade.getLeaveById(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(records));
    }



 @RequestMapping(value = "/getCompanyByManage.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "集团人事报表",
            notes = "集团人事报表",
            httpMethod = "POST",
            response = ResponseUtils.class,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jsonData", value = "", dataType = "String", paramType = "body")
    })
    public void getCompanyByManage(HttpServletRequest request, HttpServletResponse response) {
        List<JSONObject> records = this.personnelFacade.getCompanyByManage();
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(records));
    }

    @RequestMapping(value = "/getSaleByManage.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "销售管理人事报表",
            notes = "销售管理人事报表",
            httpMethod = "POST",
            response = ResponseUtils.class,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jsonData", value = "{companyId:'2017121617464D12B1025EC2259267D2'}", dataType = "String", paramType = "body")
    })
    public void getSaleByManage(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> records = this.personnelFacade.getSaleByManage(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(records));
    }

    @RequestMapping(value = "/getRegionByManager.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "人事报表",
            notes = "人事报表",
            httpMethod = "POST",
            response = ResponseUtils.class,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jsonData", value = "{departId:'2018012014424BE09F409EDA1A7ADEE3'}", dataType = "String", paramType = "body")
    })
    public void getRegionByManager(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> records = this.personnelFacade.getRegionByManager(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(records));
    }
    @RequestMapping(value = "/getSupportRegionList.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "人事报表",
            notes = "人事报表",
            httpMethod = "POST",
            response = ResponseUtils.class,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jsonData", value = "{userId:'20171216210645E3BA468BFE78843717'}", dataType = "String", paramType = "body")
    })
    public void getSupportRegionList(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> records = this.personnelFacade.getSupportRegionList(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(records));
    }
}
